package com.guhappy.action.generalContest;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.guhappy.model.contest.ContestHome;
import com.guhappy.model.contest.GeneralContestView;
import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("default")
@Action(value="contest",results={@Result(name="success", location="/pages/generalContestView.jsp")})
public class GeneralContest extends ActionSupport implements ServletRequestAware{
	
	private GeneralContestView contestviewthree;
	private GeneralContestView contestviewmonthly;
	private GeneralContestView contestviewweekly;
	private GeneralContestView contestviewquarterly;
	private GeneralContestView contestviewyearly;
	private String region;
	private String direction;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	HttpServletRequest request;

	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
	}
	
	public HttpServletRequest getServletRequest() {
		return this.request;
	}

	@Override
	public String execute() throws Exception {
		if (region==null) 
			region = "0";
		if (direction == null)
			direction = "UP";
		contestviewmonthly = ContestHome.getContestViewMonthly(region,direction);
		contestviewthree = ContestHome.getContestViewTree(region,direction);
		contestviewweekly = ContestHome.getContestViewWeekly(region,direction);
		contestviewquarterly = ContestHome.getContestViewQuarter(region,direction);
		contestviewyearly = ContestHome.getContestViewYear(region,direction);
		return SUCCESS;
	}

	public GeneralContestView getContestviewthree() {
		return contestviewthree;
	}

	public void setContestviewthree(GeneralContestView contestviewthree) {
		this.contestviewthree = contestviewthree;
	}

	public GeneralContestView getContestviewweekly() {
		return contestviewweekly;
	}

	public void setContestviewweekly(GeneralContestView contestviewweekly) {
		this.contestviewweekly = contestviewweekly;
	}

	public GeneralContestView getContestviewquarterly() {
		return contestviewquarterly;
	}

	public void setContestviewquarterly(GeneralContestView contestviewquarterly) {
		this.contestviewquarterly = contestviewquarterly;
	}

	public GeneralContestView getContestviewyearly() {
		return contestviewyearly;
	}

	public void setContestviewyearly(GeneralContestView contestviewyearly) {
		this.contestviewyearly = contestviewyearly;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public GeneralContestView getContestviewmonthly() {
		return contestviewmonthly;
	}

	public void setContestviewmonthly(GeneralContestView contestviewmonthly) {
		this.contestviewmonthly = contestviewmonthly;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getDirection() {
		return direction;
	}

	public void setDirection(String direction) {
		this.direction = direction;
	}

}
